Project Overview :
● A self-driving vehicle, also known as an autonomous vehicle or rover, is a vehicle that is capable of traveling without human input.
● The vehicle will drive itself as it programmed. If will detect object and it’s distance using ultrasonic sensor it will do actions based on the distance.
Requirements :
● Jetson Nano development kit.
● L298N Motor Driver Module.
● LM2596 DC-DC Buck Converter Step Down Module.
● DC Motors and chassis.
● Battery .
● Ultrasonic sensor.
Initial setup for :
📚 Click Here , for the initial setup
Here is the image of rover,
Circuit connection :
CONNECTION TABLE :
| RPI | I/O | Components |
|---|---|---|
| 5V | OUT + | Buck converter |
| GND | OUT - | Buck converter |
| BATTERY | 12V | L298N H Bridge |
| GND | GND | L298N H Bridge |
| GPIO33 | ENA | L298N H Bridge |
| GPIO22 | IN1 | L298N H Bridge |
| GPIO23 | IN2 | L298N H Bridge |
| GPIO24 | IN3 | L298N H Bridge |
| GPIO25 | IN4 | L298N H Bridge |
| GPIO34 | ENB | L298N H Bridge |
| 5V | VCC | Ultrasonic Sensor |
| GPIO7 | TRIG | Ultrasonic Sensor |
| GPIO8 | ECHO | Ultrasonic Sensor |
| GND | GND | Ultrasonic Sensor |
SPECIFICATION :
Jetson Nano development kit :
● NVIDIA Jetson Nano is an embedded system-on-module (SoM) and developer kit from the NVIDIA Jetson family, including an integrated 128-core Maxwell GPU, quad-core ARM A57 64-bit CPU, 4GB LPDDR4 memory, along with support for MIPI CSI-2 and PCIe Gen2 high-speed I/O.
● There is also the Jetson Nano 2GB Developer Kit with 2GB memory and the same processing specs.
● Useful for deploying computer vision and deep learning, Jetson Nano runs Linux and provides 472 GFLOPS of FP16 compute performance with 5-10W of power consumption.
Ultrasonic Sensor :
● An ultrasonic sensor is used to detect any obstacle in front of it and sends a command to the micro- controller.
● Depending on the input signal received, the micro-controller redirects the vehicle to move in an alternate direction by actuating the motors which are interfaced to it through a motor driver.
● Reflected sound waves are used by ultrasonic sensors to determine an object's distance.
● Ultrasonic sensors, also known as ultrasonic transducers, are frequently utilized in low-speed systems because to their comparatively small effective working range of about 2 meters.
L298N Motor Driver Module :
● The L298N Motor Driver module consists of an L298 Motor Driver IC, 78M05 Voltage Regulator, resistors, capacitor, Power LED, 5V jumper in an integrated circuit.
● When the power supply is less than or equal to 12V, then the internal circuitry will be powered by the voltage regulator and the 5V pin can be used as an output pin to power the microcontroller.
● The jumper should not be placed when the power supply is greater than 12V and separate 5V should be given through 5V terminal to power the internal circuitry.
● ENA & ENB pins are speed control pins for Motor A and Motor B while IN1& IN2 and IN3 & IN4 are direction control pins for Motor 1 and Motor 2.
● Driver Model: L298N 2A .
● Driver Chip: Double H Bridge L298N.
● Motor Supply Voltage (Maximum): 46V.
● Motor Supply Current (Maximum): 2A.
● Logic Voltage: 5V.
● Driver Voltage: 5-35V.
● Driver Current:2A.
● Logical Current:0-36mA.
● Maximum Power (W): 25W.
● Current Sense for each motor.
● Heatsink for better performance.
● Power-On LED indicator.
DC motor :
● A DC motor is any motor within a class of electrical machines whereby direct current electrical power is converted into mechanical power.
● High torque is the biggest advantage of using DC motors in robotics.
● The direction of current flow in part of the motor is changed periodically.
● The speed of a DC motor is controlled using a variable supply voltage or by changing the strength of the current within its field wind rings.
● While smaller DC motors are commonly used in the making of appliances, tools, toys, and automobile mechanisms, such as electric car seats, larger DC motors are used in hoists, elevators, and electric vehicles.
LM2596 DC-DC Buck Converter Step Down Module
● Input: DC 3V to 40V (input voltage must be higher than the output voltage to 1.5v above cannot boost)
● Output: DC 1.5V to 35V voltage continuously adjustable, high-efficiency maximum output current of 3A
● Features: All Sanyo solid capacitors, the 36u thickening circuit boards, high-Q inductance with output value of high-power LED indicator.
Code :
import Jetson.GPIO as GPIO from time import sleep import time trig=7 echo=8 m1=22 m2=23 m3=24 m4=25 pwm1=12 pwm2=27 speed=70 GPIO.setmode(GPIO.BOARD) GPIO.setup(m1,GPIO.OUT) GPIO.setup(m2,GPIO.OUT) GPIO.setup(m3,GPIO.OUT) GPIO.setup(m4,GPIO.OUT) GPIO.setup(pwm1,GPIO.OUT) GPIO.setup(pwm2,GPIO.OUT) GPIO.setup(trig,GPIO.OUT) GPIO.setup(echo,GPIO.IN) p=GPIO.PWM(pwm1,1000) p2=GPIO.PWM(pwm2,1000) p.start(speed-5) p2.start(speed) def distance(): GPIO.output(trig,GPIO.HIGH) sleep(0.00001) GPIO.output(trig,GPIO.LOW) StartTime= time.time() StopTime= time.time() while GPIO.input(echo) ==0: StartTime = time.time() while GPIO.input(echo) ==1: StopTime = time.time() TimeElapsed = StopTime - StartTime Distance = (TimeElapsed * 34300) /2 return Distance def f(): GPIO.output(m1,GPIO.HIGH) GPIO.output(m2,GPIO.LOW) GPIO.output(m3,GPIO.HIGH) GPIO.output(m4,GPIO.LOW) def b(): GPIO.output(m2,GPIO.HIGH) GPIO.output(m1,GPIO.LOW) GPIO.output(m4,GPIO.HIGH) GPIO.output(m3,GPIO.LOW) def l(): GPIO.output(m1,GPIO.LOW) GPIO.output(m2,GPIO.HIGH) GPIO.output(m3,GPIO.HIGH) GPIO.output(m4,GPIO.LOW) def r(): GPIO.output(m1,GPIO.HIGH) GPIO.output(m2,GPIO.LOW) GPIO.output(m3,GPIO.LOW) GPIO.output(m4,GPIO.HIGH) def s(): GPIO.output(m2,GPIO.LOW) GPIO.output(m1,GPIO.LOW) GPIO.output(m4,GPIO.LOW) GPIO.output(m3,GPIO.LOW) """a=2 for i in range(a): f() sleep(1) print('Forword') s() sleep(1) b() sleep(1) print('Backword') s() sleep(1) l() sleep(1) print('left') s() sleep(1) r() sleep(1) print('right') s() sleep(1) """ try: while True: dist= distance() if dist <= 10: b() sleep(1) f() elif dist <= 20: s() print(str(dist) +" :Object Detected ") else: f() sleep(0.1) except KeyboardInterrupt: print("stopped by user") GPIO.cleanup()
OUTPUT :